export default {
  namespaced: true,
  state: () => ({
    token: 'Bearer abc',
    list: ['pink', 'red', 'blue']
  }), // 分模块的时候state建议写成一个函数的形式
  mutations: {
    fn (state, payload) {
      state.list.push(payload)
    }
  },
  actions: {
    fnAsync (context) {
      // 只要是定时器在项目中肯定箭头函数
      setTimeout(() => {
        context.commit('fn', 'black')
      }, 2000)
    }
  },
  getters: {
    num (state) {
      return state.list.length
    }
  }
}
